<?php

namespace App\Http\Validate\Order;

use App\Http\Validate\BaseValidate;

/**
 * 销售订单验证器
 */
class Saleorder extends BaseValidate
{
    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];

    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
                'document_date' => 'required',
                'bill_type' => 'required',
                'business_type' => 'required',
                'custom_id' => 'required',
                'custom_level' => 'required',
                'custom_name' => 'required',
                'settlement_company' => 'required',
                'extra_type' => 'required|in:1,2',
                'order_type' => 'required|in:1,2,3,4',
            ];
            $this->message = [
                'document_date.required' => '单据日期不能为空',
                'bill_type.required' => '票据类型不能为空',
                'business_type.required' => '业务类型不能为空',
                'custom_id.required' => '客户id不能为空',
                'custom_level.required' => '客户价等级不能为空',
                'custom_name.required' => '客户名称不能为空',
                'settlement_company.required' => '结算客户不能为空',
                'extra_type.required' => '加价规则不能为空',
                'extra_type.in' => '加价规则参数无效',
                'order_type.required' => '销售订单类型不能为空',
                'order_type.in' => '销售订单类型参数无效',
            ];
        } elseif ($doaction == 'edit') {
            $this->rule = [
                'document_date' => 'required',
            ];
            $this->message = [
                'document_date.required' => '单据日期不能为空',
            ];
        } elseif ($doaction == 'handlebelow') {
            $this->rule = [
                'id' => 'required',
                'examine_status' => 'required|in:2,3,4',
            ];
            $this->message = [
                'id.required' => '订单id不能为空',
                'examine_status.required' => '审核状态不能为空',
                'examine_status.in' => '无效参数',
            ];
        } elseif ($doaction == 'handledel') {
            $this->rule = [
                'id' => 'required',
                'del_status' => 'required|in:1,3,4',
            ];
            $this->message = [
                'id.required' => '订单id不能为空',
                'del_status.required' => '删除状态不能为空',
                'del_status.in' => '无效参数',
            ];
        } elseif ($doaction == 'order_status') {
            $this->rule = [
                'id' => 'required',
                'order_status' => 'required|in:1,2,3,4',
            ];
            $this->message = [
                'id.required' => '订单id不能为空',
                'order_status.required' => '状态不能为空',
                'order_status.in' => '无效参数',
            ];
        }
    }
}
